//
//  JLData.m
//  Liang美团HD
//
//  Created by sun on 16/1/20.
//  Copyright © 2016年 sun. All rights reserved.
//

#import "JLData.h"
#import <MJExtension.h>
#import "JLSort.h"
#import "JLCategories.h"
#import "JLCiteGroup.h"
#import "JLCities.h"
static  NSArray * _sortArray;
static  NSArray * _categoriesArray;
static  NSArray * _cityGroupsArray;
@implementation JLData
+(NSArray *)sortArray{
    if (_sortArray == nil) {
        _sortArray = [JLSort mj_objectArrayWithFilename:@"sorts.plist"];
    }
    return _sortArray;
}

+(NSArray *)categoriesArray{
    if (_categoriesArray == nil) {
        _categoriesArray = [JLCategories mj_objectArrayWithFilename:@"categories.plist"];
    }
    return _categoriesArray;
}
+(NSArray *)cityGroupsArray{
    if (_cityGroupsArray == nil) {
        _cityGroupsArray = [JLCiteGroup mj_objectArrayWithFilename:@"cityGroups.plist"];
    }
    return _cityGroupsArray;
}
static  NSArray * _cities;
+(NSArray *)citiesArray{
    if (_cities == nil) {
        _cities = [JLCities mj_objectArrayWithFilename:@"cities.plist"];
    }
    return _cities;
}
+(NSArray *)citiesWithName:(NSString *)name{
    if (name.length == 0) return nil;
  return [[self citiesArray] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name contains %@ or pinYin contains %@ or pinYinHead contains %@",name,name,name]];
    
}
+(JLCities *)searchCitiesWithName:(NSString *)name{
    if (name.length == 0) return nil;
    return [[self citiesArray] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name == %@",name]].firstObject;
}
@end
